const { Article } = require('../../model/article');
module.exports = async(req, res) => {
    req.app.locals.currentLink = 'article';
    let id = req.query.id;
    if (id) {
        const article = await Article.findOne({ _id: id });
        res.render('admin/article-edit', {
            article,
            link: '/admin/article-edit'
        });
    } else {
        res.render('admin/article-edit', { link: '/admin/article-add' });
    }
}